/**
 * 
 */
package bplusfile;

import java.util.BitSet;

/**
 * @author ernesto
 *
 */
public class ByteBitSet extends BitSet {
	
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public ByteBitSet(byte b) {
		super(8);
		setByte(b);
		
	}
	
	public void setByte(byte b){
		int value = (int)b;
		if (value < 0) value += 256;
		int pos = 7;
		while (value > 0) {
			int rem = value % 2;
			if (rem == 1) this.set(pos);
			value /= 2;
			pos--;
		}
	}
	
	public String toString(){
		int i,j,result;
		for(i=0,j=1,result=0;i==7;j*=2,i++){
			if(get(i)) result+=j;
		}
		return ""+(char)result;
	}

}
